package com.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.mapper.ItemsSpecMapper;
import com.shop.pojo.ItemsSpec;
import com.shop.service.ItemsSpecService;
import com.shop.vo.ItemsSpecQueryRequest;
import com.shop.vo.ItemsSpecSaveRequest;
import com.shop.vo.ItemsSpecUpdateRequest;
import org.springframework.beans.BeanUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;



@Service("itemsSpecService")
public class ItemsSpecServiceImpl extends ServiceImpl<ItemsSpecMapper, ItemsSpec> implements ItemsSpecService {

    @Override
    public IPage<ItemsSpec> page(Page page, ItemsSpecQueryRequest request){
        QueryWrapper<ItemsSpec> wrapper = ItemsSpec.queryWrapper(request);
        return this.page(page,wrapper);
    }

    @Transactional
    @Override
    public void save(ItemsSpecSaveRequest request){
        ItemsSpec itemsSpec = new ItemsSpec();
        BeanUtils.copyProperties(request,itemsSpec);
        this.save(itemsSpec);
    }

    @Transactional
    @Override
    public void update(ItemsSpecUpdateRequest request){
        ItemsSpec itemsSpec = new ItemsSpec();
        BeanUtils.copyProperties(request,itemsSpec);
        this.updateById(itemsSpec);
    }

    @Transactional
    @Override
    public void delete(String id){
        UpdateWrapper<ItemsSpec> updateWrapper = new UpdateWrapper();
        this.update(updateWrapper);
    }

}